﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Wizard.UI
{
    [DefaultEvent("SetActive")]
    public partial class WizardPage : UserControl
    {
        public WizardPage()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Fired when the wizard changes to this page.
        /// </summary>
        [Category("Wizard")]
        public event CancelEventHandler SetActive;

        public virtual void OnSetActive(CancelEventArgs e)
        {
            if (SetActive != null)
                SetActive(this, e);
        }

        /// <summary>
        /// Fired when the wizard is moving to the next page.
        /// </summary>
        [Category("Wizard")]
        public event WizardPageEventHandler WizardNext;

        public virtual void OnWizardNext(WizardPageEventArgs e)
        {
            if (WizardNext != null)
                WizardNext(this, e);
        }

        /// <summary>
        /// Fired when the wizard is moving to the previous page.
        /// </summary>
        [Category("Wizard")]
        public event WizardPageEventHandler WizardBack;

        public virtual void OnWizardBack(WizardPageEventArgs e)
        {
            if (WizardBack != null)
                WizardBack(this, e);
        }

        /// <summary>
        /// Fired when the wizard is finishing.
        /// </summary>
        [Category("Wizard")]
        public event CancelEventHandler WizardFinish;

        public virtual void OnWizardFinish(CancelEventArgs e)
        {
            if (WizardFinish != null)
                WizardFinish(this, e);
        }

        /// <summary>
        /// Retrieves the WizardSheet that owns this WizardPage.
        /// </summary>
        /// <returns>The WizardSheet that owns this WizardPage.</returns>
        protected WizardSheet GetWizard()
        {
            WizardSheet wizard = (WizardSheet)this.ParentForm;
            return wizard;
        }

        /// <summary>
        /// Sets the active buttons on the WizardSheet.
        /// </summary>
        /// <param name="buttons">An enumeration describing the buttons to be shown.</param>
        protected void SetWizardButtons(WizardButtons buttons)
        {
            GetWizard().SetWizardButtons(buttons);
        }

        /// <summary>
        /// Sets whether the UAC shield icon is displayed on
        /// the Next and Finish buttons.
        /// </summary>
        /// <param name="required">Whether the UAC shield is to be shown.</param>
        protected void SetUACRequired(bool required)
        {
            GetWizard().SetUACRequired(required);
        }
    }
}
